-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Check structs and enums for use_self
#15566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Lintcheck changes for abab6c7
This comment will be updated if you push new changes |
Hello. The implementation of this change turned out to be almost suspiciously easy. I tried to be thorough with testing. Happy to add more cases (lifetimes, etc). I browsed through the new lintcheck added lines. They seem to be fine. There are a few changed lines, but they seem unrelated to this PR? Not sure. Probably need doc changes here or there too. Will do if changes are okay. |
Hi Nick! |
0b641e4
to
cb6a211
Compare
This comment has been minimized.
This comment has been minimized.
Addressed @ada4a 's comments. Updated Clippy sites flagged by lint. Eagerly awaiting feature thaw 🐈 |
cb6a211
to
fb748b4
Compare
This comment has been minimized.
This comment has been minimized.
fb748b4
to
c01764b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c01764b
to
83ebe9a
Compare
This comment has been minimized.
This comment has been minimized.
I'm not sure if we want to actually go forward with this. Like, using They're hosted on our channel on Zulip =^w^= |
Recursive #[derive(Clone, Copy)]
enum NormalizedPat<'a> {
Wild,
Never,
Struct(Option<DefId>, &'a [(Symbol, Self)]), // <--
Tuple(Option<DefId>, &'a [Self]), // <--
Or(&'a [Self]), // <--
Path(Option<DefId>),
LitStr(Symbol),
LitBytes(ByteSymbol),
LitInt(u128),
LitBool(bool),
Range(PatRange),
/// A slice pattern. If the second value is `None`, then this matches an exact size. Otherwise
/// the first value contains everything before the `..` wildcard pattern, and the second value
/// contains everything afterwards. Note that either side, or both sides, may contain zero
/// patterns.
Slice(&'a [Self], Option<&'a [Self]>), // <--
/// A placeholder for a pattern that wasn't well formed in some way.
Err(ErrorGuaranteed),
} Use of If Part of the purpose of a linter like Clippy is to encourage use of language features. "I see you have a recursive |
Hello. I would like to get this merged soon. Sounds like the result of the meeting is to add this new check, but include a config option to disable it. What should be the name / description of the option? |
This comment has been minimized.
This comment has been minimized.
83ebe9a
to
292d7ef
Compare
This comment has been minimized.
This comment has been minimized.
Recent change #15773 illustrates the benefits of |
Hi Nick, sorry for the delay. I thought I had responded one of the last 3 times I revisited this pull request this week.
|
292d7ef
to
78c5b08
Compare
This comment has been minimized.
This comment has been minimized.
e51831f
to
25f3315
Compare
@rustbot ready |
@rustbot note remove Feature-freeze |
Since it applies to enums as well, maybe it should be |
I've thought about it, but decided to just mention structs (extending it to enums in the description) because I don't think anybody outside of the compiler space knows what an ADT actually is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of adjustments, and this is ready!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being that we have a configuration option for this lint now, we'll have to move it to tests/ui-toml
and add both cases (luckily, as we use ui_test
, the process isn't too tedious).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a basic test to demonstrate that new functionality is disabled when flag is set to false and existing functionality is unaffected. Hopefully it follows conventions closely enough.
25f3315
to
abab6c7
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Closes #15555
changelog: [
use_self
]: Check structs and enums